<html>
<head>

<script id='vertex' type='x-shader/x-vertex'>
attribute vec3 aCoord;
attribute vec2 aTexCoord;
attribute vec2 aPhase;
uniform mat4 uPMatrix;
uniform mat4 uMVMatrix;
varying vec2 vCoord;
varying vec2 vPhase;

void main() {
    gl_Position = uPMatrix * uMVMatrix * vec4(aCoord, 1.0);
    vCoord = aTexCoord;
    vPhase = aPhase;
}
</script>

<script id='fragment' type='x-shader/x-fragment'>
precision mediump float;
uniform sampler2D uTexture;
varying vec2 vCoord;
varying vec2 vPhase;

void main() {
    gl_FragColor = texture2D(uTexture, vCoord);
}
</script>

<script id='fragmentForCeiling' type='x-shader/x-fragment'>
precision mediump float;
uniform sampler2D uTexture;
varying vec2 vCoord;
varying vec2 vPhase;

void main() {
    vec2 l = 0.1 / (0.1 + sin(vPhase) * sin(vPhase));
    vec3 c = texture2D(uTexture, vCoord).rgb * l.x * l.y;
    gl_FragColor = vec4(c.rg * 0.7, c.b, 1.0);
}
</script>

</head>
</html>
